package com.jlect.swebing.ui.client;

import java.util.ArrayList;

/**
 * Property listener collection
 *
 * @author Sergey Kozmin
 * @since 06.12.2007 10:30:19
 */
public class PropertyListenerCollection extends ArrayList {
    private PropertyChangeEvent event;
    public void eventAppeared(GComponent source, String name, Object oldValue, Object newValue) {
        if(event == null) {
            event = new PropertyChangeEvent(source, name, oldValue, newValue);
        } else {
            event.init(source, name, oldValue, name);
        }
        fireEvent(event);
    }

    private void fireEvent(PropertyChangeEvent event) {
        for (int i = 0; i < size(); i++) {
            PropertyChangeListener listener = (PropertyChangeListener) get(i);
            listener.propertyChange(event);
        }
    }
}
